<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<style>
    .active {
        color: red;
    }
</style>
<body>
    <div id="app">
        <ul>
            <li v-for="(movie,index) in movies" :class="{active:currentIndex==index}" @click="liclick(index)">{{movie}}</li>
        </ul>
    </div>

    <script>
        //创建Vue实例,得到 ViewModel
        var vm = new Vue({
            el: '#app',
            data: {
                movies: ['哈利波特', '速度与激情', '大话西游', '笑林小子', '变形金刚', '大黄蜂'],
                currentIndex: 0
            },
            methods: {
                liclick(index){
                    this.currentIndex = index;
                }
            }
        });
    </script>
</body>

</html>